package user

import (
	"context"
	"user-api/api/user"
	userLogic "user-api/internal/logic/user"
)

type PersonalController struct {
}

func NewPersonalController() *PersonalController {
	return &PersonalController{}
}

// login
func (p *PersonalController) Login(ctx context.Context, req *user.LoginReq) (res *user.LoginRes, err error) {
	userLogic := userLogic.NewPersonalLogic()
	return userLogic.Login(ctx, req)
}

// createUserInfo
func (p *PersonalController) CreateUser(ctx context.Context, req *user.CreateUserReq) (res *user.CreateUserRes, err error) {
	//创建用户
	userLogic := userLogic.NewPersonalLogic()
	createUser, err := userLogic.CreateUser(ctx, req)
	if err != nil {
		return &user.CreateUserRes{}, err
	}
	if err != nil {
		return &user.CreateUserRes{}, err
	}
	return createUser, nil
}

// updateUserInfo
func (p *PersonalController) UpdateUser(ctx context.Context, req *user.UpdateUserReq) (res *user.UpdateUserRes, err error) {
	userLogic := userLogic.NewPersonalLogic()
	return userLogic.UpdateUser(ctx, req)
}

// getUserlist
func (p *PersonalController) UserList(ctx context.Context, req *user.UserPageReq) (res *user.UserPageRes, err error) {
	userLogic := userLogic.NewPersonalLogic()
	return userLogic.UserList(ctx, req)

}

// getUserInfo
func (p *PersonalController) UserInfo(ctx context.Context, req *user.UserInfoReq) (res *user.UserInfoRes, err error) {
	userLogic := userLogic.NewPersonalLogic()
	return userLogic.UserInfo(ctx, req)

}

// deleteUser
func (p *PersonalController) DeleteUser(ctx context.Context, req *user.DeleteUserReq) (res *user.DeleteUserRes, err error) {
	userLogic := userLogic.NewPersonalLogic()
	return userLogic.DeleteUser(ctx, req)

}
